package com.lan.iot;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.CompoundButton;
import android.widget.ListView;
import android.widget.Switch;

import java.util.ArrayList;
import java.util.List;

import static com.lan.iot.Activity_index.offtime;
import static com.lan.iot.Activity_index.ontime;

public class About extends AppCompatActivity {
    private static List<String> settings = new ArrayList<>();

    {
        settings.add("官方网页");
        settings.add("检查更新");
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

            Window window = getWindow();

            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS

                    | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION

                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);

            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

            window.setStatusBarColor(Color.TRANSPARENT);

            window.setNavigationBarColor(Color.TRANSPARENT);
        }
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.activity_about);
        List<String> setting = new ArrayList<>();
        for (int i = 0; i < 2; i++) {
            setting.add(settings.get(i));
        }
        ListAdapter_about adapter = new ListAdapter_about(About.this, R.layout.item_, setting);
        ListView listView = findViewById(R.id.lv);
        //将适配器中数据添加到ListView中
        listView.setAdapter(adapter);
        final Switch sw = findViewById(R.id.sw);
       sw.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View view) {
               if (sw.isChecked()) {
                   ontime();
               } else {
                   offtime();
               }
           }
       });
       sw.setChecked(true);
    }
}
